<?php

namespace App\Http\Requests\dispatch;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait DriverRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
            'type' => 'required|integer|between:1,2',
            'name' => 'required|max:20|min:1',
            'mobile' => 'required|max:20|min:1',
            'id_number' => 'required|max:20|min:1',
            'login_mobile' => 'required|max:20|min:1',
//            'login_password' => 'required|max:20|min:1',
        ], [
            'type.required' => '请选择类型',
            'name.required' => '请填写姓名',
            'mobile.required' => '请填写电话',
            'id_number.required' => '请填写身份证号',
            'login_mobile.required' => '请填写登录手机号',
//            'login_password.required' => '请填写登录密码',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
